package com.classic.administrator.pachong;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.util.Log;

import com.classic.base.UBaseSplashActivity;
import com.classic.utils.ADUtils;

import permissions.dispatcher.NeedsPermission;
import permissions.dispatcher.OnNeverAskAgain;
import permissions.dispatcher.OnPermissionDenied;
import permissions.dispatcher.OnShowRationale;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.RuntimePermissions;

/**
 * 启动页
 */
@RuntimePermissions
public class SplashActivity extends UBaseSplashActivity {

    @Override
    protected String getChannel() {
        return "huawei";
    }

    @Override
    protected int getImg() {
        return R.mipmap.ic_xiaohua;
    }
    @Override
    protected int getImgLogo() {
        return R.mipmap.ic_back;
    }

    @Override
    public double getImgLogoScale(int height) {
        return height*200/927;
    }

    @Override
    protected void initPermission() {
        SplashActivityPermissionsDispatcher.onNeedWithPermissionCheck(this);
        Log.d("---yyy--","111");
    }

    @Override
    protected void initData() {

    }


    @SuppressLint("NeedOnRequestPermissionsResult")
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        SplashActivityPermissionsDispatcher.onRequestPermissionsResult(this, requestCode, grantResults);
    }


    @Override
    public void starMain() {
        startActivity(new Intent(SplashActivity.this, MainActivity.class));
        finish();
    }

    @NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    void onNeed() {     Log.d("---yyy--","222");
        initADType();
    }

    @SuppressLint("NoCorrespondingNeedsPermission")
    @OnShowRationale({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onShowRationale1(final PermissionRequest request) {
        request.proceed();
    }

    @OnNeverAskAgain({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onNeverAsk1() {
        Log.d("-----------","1323");
        showDialog();
        isTrue = false;
    }

    @OnPermissionDenied({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
    public void onPermission1() {
        SplashActivityPermissionsDispatcher.onNeedWithPermissionCheck(SplashActivity.this);
    }

    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }


}